﻿<!--#include file="../../Inc/Const.Asp"-->
<%
dim plus
set plus = new cls_plus
plus.open("comment")
plus.state
plus.newtpl("plus_comment.html")

' 评论显示
Dim ID
Dim Page
ID = Request("id")
Page = Request("p")
If Len(ID) = 0 Or Not IsNumeric(ID) Then Response.WRite Plus.Lang("iderr") : Set plus = Nothing : Response.End
If Len(Page) = 0 Or Not IsNumeric(Page) Then Page = 1
If Page < 1 Then Page = 1 else Page = int(Page)
If Len(Session("Comment_User")) < 1 Then Session("Comment_User") = "Guest"

Dim Ns
Set Ns = DB("Select [ID],[Cid],[Title],[Diyname],[Createtime],[comments],[Viewpath] From [{pre}Content] Where [ID]=" & ID,1)
If Ns.Eof Then
	Ns.CLose
	Conn.CLose
	Response.Write Plus.Lang("nocontent")
	Set Conn = Nothing
	Set Plus = Nothing
	Response.End
End If

Dim Url
Url = BuildViewPath(Ns("ID"),Ns("Cid"),Ns("Diyname"),Ns("Createtime"),Ns("Viewpath"))

Dim Rs
Set Rs = DB("select [User],[IP],[Time],[Content],[ReComment] From [{pre}Comment] Where [Aid]=" & ID & " And [State]=1 Order by [ID] desc",2)

Dim Comment,CommentPageList
Dim Poster,Repost,UserIP
Poster = Plus.Lang("js-poster")
Repost = Plus.Lang("js-repost")

If Not Rs.Eof Then
	Rs.Pagesize = Plus.Config("pagesize")
	Rs.absolutePage = Page
	Dim i
	For i = 1 to Rs.Pagesize
		If Rs.eof Then Exit For
		UserIP = Split(Rs(1),".")
		Comment = Comment & "<dl>" & Vbcrlf
		if ubound(userip)>=2 then
		Comment = Comment & "<dt><strong>" & Rs(0) & "(" & UserIP(0) & "." & UserIP(1) & "." & UserIP(2) & ".*) </strong>" & Poster & "<span>" & Rs(2) & "</span></dt>" & VbCrlf
		else
		Comment = Comment & "<dt><strong>" & Rs(0) & " </strong>" & Poster & "<span>" & Rs(2) & "</span></dt>" & VbCrlf
		end if
		Comment = Comment & "<dd>" & Replace(Replace(Rs(3),Vbcrlf,""),"""","\""") & "<br/>" & VbCrlf
		If Len(Rs(4))>0 Then
		Comment = Comment & Repost & "<font color=red>" & Replace(Replace(Rs(4),Vbcrlf,""),"""","\""") & "</font>" & VbCrlf
		End If
		Comment = Comment & "</dd>" & VbCrlf
		Comment = Comment & "</dl>" & VbCrlf
		Rs.MoveNext
	Next
	For i = 1 to Rs.Pagecount
		If Page = i Then
			CommentPageList = CommentPageList & "<a href=index.asp?id=" & id & "&p=" & i & " class=current>" & i & "</a>"
		Else
			CommentPageList = CommentPageList & "<a href=index.asp?id=" & id & "&p=" & i & " >" & i & "</a>"
		End If
	Next
End If

call plus.settpl("{id}",ID)
call plus.settpl("{url}",Url)
call plus.settpl("{title}",Ns(2))
call plus.settpl("{comments}",Ns(5))
call plus.settpl("{pagelist}",CommentPageList)
call plus.settpl("{contentmax}",Plus.Config("contentmax"))
call plus.settpl("{comment}",Comment)
Response.Write plus.gettpl
Ns.CLose
Rs.Close
Conn.CLose
Set Conn = Nothing
Set Plus = Nothing
%>